/**
 * Created by YY on 2016/9/9.
 */
angular.module('account', ['helper'])
  .factory('Name', function ($http, $log, Url) {
    var self = {};
    var url = Url('account-secure/account-profile');
    var name;
    self.getName = function (callback) {
      if (name) {
        $log.info('name from cache');
        return callback(name);
      }
      $http.get(url).then(function (res) {
        name = res.data.data.name ? res.data.data.name : 'error';
        callback(name);
      })
    };
    return self;
  });